package parser;

import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Scanner;

import scanner.Token;

public class Utility {

	public static File createInputSpecificationFile(String regex)
	{
		File retval = null;
	
		try{
		retval = new File("tempinputspecification.txt");
		PrintWriter writer = new PrintWriter(retval);
		writer.write("%% Token Definition "+regex+" \n");
		
		writer.write("$regex "+regex);
		writer.close();
		}catch(IOException e){System.out.println(e);}
		
		return retval;
	}
	public static String scanMiniRE()
	{
		//ArrayList<String> retval = new ArrayList<String>();
		String input = "";
		try{
		Scanner scan = new Scanner(new File("./minire_test_script.txt"));
		
		while(scan.hasNext())
			input += scan.next();
		scan.close();
		input = input.replace("\t", "");
		input = input.replace("\n", "");
		input = input.replace("\r", "");
		}catch(IOException e){System.out.println(e);}
		System.out.println(input);
		return input;
	}
	public static ArrayList<Token> getTokens()
	{
		ArrayList<Token> retval = new ArrayList<Token>();
		String input = Utility.scanMiniRE();
		
		for(int i=0;i<input.length();i++)
		{
			retval.add(new Token(Character.toString(input.charAt(i)),""));
		}
		return retval;
	}
	
	
	public static void main(String args[])
	{
		Utility.scanMiniRE();
	}
}
